using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/*
public class WeaponsInput : MonoBehaviour {
	
	public WeaponLaunchPoints LaunchPointProperties = null;
	public Launcher MissileLauncher = null;
	public Launcher BulletLauncher = null;
	public int MissileAmmo
	{
		get { return msslLaunchInstance.CurrentAmmo; }
	}
	public int BulletAmmo
	{
		get { return bullLaunchInstance.CurrentAmmo; }
	}
	public float AlignmentDistance = 10000; //the distance from the screen that dumbfire weapons should be aligned for
	
	private Launcher msslLaunchInstance;
	private Launcher bullLaunchInstance;
	private List<Transform> missileLaunchPoints = null;
	private List<Transform> bulletLaunchPoints = null;
	//since this is a player input script, there should be a camera attached to this object.
	private Camera actorCamera = null;
	
	private Transform lockOnTarget = null;
	private int nextLaunchPointIndex = 0; //designates next point on model to launch missiles from
	
	private Quaternion[] missileAimingHeadings;
	private Quaternion[] bulletAimingHeadings;
	
	// Use this for initialization
	void Start () {
		//get our launch points for our weapons
		LaunchPointProperties = GetComponentInChildren<WeaponLaunchPoints>();
		missileLaunchPoints = LaunchPointProperties.MissileLaunchPoints;
		bulletLaunchPoints = LaunchPointProperties.BulletLaunchPoints;
		actorCamera = GetComponentInChildren<Camera>();
		missileAimingHeadings = new Quaternion[missileLaunchPoints.Count];
		bulletAimingHeadings = new Quaternion[bulletLaunchPoints.Count];
		//have to instance the launchers, so that fire rate and ammo works
		msslLaunchInstance = ((GameObject)Instantiate(MissileLauncher.gameObject)).GetComponent<Launcher>();
		bullLaunchInstance = ((GameObject)Instantiate(BulletLauncher.gameObject)).GetComponent<Launcher>();
		AnimationProcessor processor = GetComponentInChildren<AnimationProcessor>();
		msslLaunchInstance.transform.parent = processor.transform;
		bullLaunchInstance.transform.parent = processor.transform;
		MissileLauncher = msslLaunchInstance.GetComponent<Launcher>();
		BulletLauncher = bullLaunchInstance.GetComponent<Launcher>();
	}
	
	// Check to see what triggers have been pressed
	void Update () {
		//prepare our aiming headings, which will align weapons fire with the crosshair
		//the aim heading lists need to be in the same order as their respective launch point lists!
		//apparently list foreach loops follow natural order
		//the point we need to aim at
		for(int i = 0; i < missileLaunchPoints.Count; ++i)
		{
			missileLaunchPoints[i].transform.LookAt(actorCamera.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, AlignmentDistance)));
		}
		for(int i = 0; i < bulletLaunchPoints.Count; ++i)
		{
			bulletLaunchPoints[i].transform.LookAt(actorCamera.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, AlignmentDistance)));
		}
		
		//missiles can only be fired the moment the trigger is pressed
		if(Input.GetButtonDown("FireMissile") && msslLaunchInstance != null && missileLaunchPoints != null)
		{
			//if we have missile launchers, fire from the next launch point
			for(int i = 0; i < missileLaunchPoints.Count; ++i)
			{
				if(i == nextLaunchPointIndex)
				{
					//TODO: figure out animations! if we could link the arms to the mouselook,
					//we wouldn't need the camera's transform to orient the weapons
					//GameObject newMissile = (GameObject)Instantiate(Missile, 
					//												missileLaunchPoints[i].position + transform.forward * 4.0f, 
					//												missileLaunchPoints[i].rotation);//ActorCamera.transform.rotation);
					
					//get the locked on target from the actor's LockOnScript, if any
					lockOnTarget = GetComponent<LockOnScript>().LockOnTarget;
					if(lockOnTarget != null)
					{
						print ("locking on to " + lockOnTarget.gameObject.name);
						//newMissile.GetComponent<MissileMovement>().Target = lockOnTarget.gameObject;
					}
					msslLaunchInstance.Fire(missileLaunchPoints[i].position + transform.forward * 4.0f, 
											missileLaunchPoints[i].rotation, 
											(lockOnTarget != null) ? lockOnTarget.gameObject : null);
				}
			}
			nextLaunchPointIndex = (nextLaunchPointIndex + 1) % missileLaunchPoints.Count;
		}
		
		//guns can fire continuously, so fire whenever the trigger's held down
		if(Input.GetButton("FireBullet") && bullLaunchInstance != null && bulletLaunchPoints != null)
		{
			for(int i = 0; i < bulletLaunchPoints.Count; ++i)
			{
				//Instantiate(Bullet, bulletLaunchPoints[i].position + transform.forward * 4.0f, bulletLaunchPoints[i].rotation);//ActorCamera.transform.rotation);
				bullLaunchInstance.Fire(bulletLaunchPoints[i].position + transform.forward * 4.0f, bulletLaunchPoints[i].rotation);
			}
		}
	}
}
*/